<template>
  <div class="app-container">
    <!--工具栏-->
    <crudOperation :permission="permission"/>
    <div class="head-container">
<!--      <div v-if="!crud.props.searchToggle">-->
<!--        <el-form size="small" label-width="70px">-->
<!--          <el-row :gutter="10">-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="客户名称">-->
<!--                <el-input></el-input>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="销售部门">-->
<!--                <el-input></el-input>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="销售人员">-->
<!--                <el-input></el-input>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="客户分类">-->
<!--                <el-input></el-input>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <el-form-item label="客户区域">-->
<!--                <el-input></el-input>-->
<!--              </el-form-item>-->
<!--            </el-col>-->
<!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
<!--              <rrOperation :crud="crud"/>-->
<!--            </el-col>-->
<!--          </el-row>-->
<!--        </el-form>-->
      </div>
    <el-dialog v-dialog-drag style="width: 80vm" title="搜索"   close-on-click-modal :visible.sync="crud.props.searchToggle"
               width="70%"  >
      <el-form size="small" label-width="70px" >
        <el-row :gutter="10">
          <el-col span="12">
            <el-form-item label="日期">
              <el-date-picker
                v-model="dataExtent"
                type="daterange"
                @change="getValue()"
                align="right"
                unlink-panels
                style="width: 100%"
                format="yyyy - MM - dd "
                value-format="yyyy-MM-dd"
                default-value
                range-separator=""
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
          <el-form-item label="仓库">
            <table-select
              :tableColumns="[{prop:'code',label:'编码',width:'100'},{prop:'name',label:'名称',width: '280'}]"
              :value.sync="query.warehouseIds"
              placeholder="请选择仓库"
              url="/api/dropDown/basWarehouseList"
            ></table-select>
          </el-form-item>
        </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="商品名称">
<!--              <el-input v-model="query.goodsKeyword" placeholder="输入商品进行搜索"/>-->
              <table-select
                :tableColumns="[{prop:'goodsCode',label:'商品编码',width:'100'},{prop:'goodsName',label:'商品名称',width: '280'}]"
                labelKey="goodsName"
                valueKey="goodsId"
                :value.sync="query.goodsIds"
                placeholder="请选择商品"
                url="/api/dropDown/basGoodsListForAdd"
              ></table-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="商品品牌">
              <table-select
                :tableColumns="[{prop:'code',label:'品牌编码',width:'100'},{prop:'name',label:'品牌名称',width: '280'}]"
                :value.sync="query.goodsBrandIds"
                placeholder="请选择品牌"
                url="/api/dropDown/basGoodsBrandList"
              ></table-select>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
            <el-form-item label="商品分类">
              <treeselect
                v-model="goodsTypeIds"
                :options="areaList"
                placeholder="商品"
                style="width: 100%"
                :normalizer="normalizer"
                multiple
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class="flex fow-reverse" >
          <el-button class="filter-item"  size="mini" type="primary" @click="queryReport">搜索</el-button>
          <el-button class="filter-item" plain   size="mini" type="primary"
                     @click="resetQuery()" >重置</el-button>
        </el-row>
      </el-form>
    </el-dialog>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="业务日期">
            <el-input v-model="form.busDate" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库id">
            <el-input v-model="form.warehouseId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库编码">
            <el-input v-model="form.warehouseCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="仓库名称">
            <el-input v-model="form.warehouseName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="单据备注">
            <el-input v-model="form.orderRemark" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品id" prop="goodsId">
            <el-input v-model="form.goodsId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品编码">
            <el-input v-model="form.goodsCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品名称">
            <el-input v-model="form.goodsName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="包装类型(1:纸箱 2:塑箱 3:其他)">
            <el-input v-model="form.packageType" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="条形码">
            <el-input v-model="form.barcode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱装条形码">
            <el-input v-model="form.boxBarcode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="助记符">
            <el-input v-model="form.helpSign" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="规格型号">
            <el-input v-model="form.model" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品品牌id">
            <el-input v-model="form.goodsBrandId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品品牌编码">
            <el-input v-model="form.goodsBrandCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品品牌名称">
            <el-input v-model="form.goodsBrandName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品分类id">
            <el-input v-model="form.goodsTypeId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品分类编码">
            <el-input v-model="form.goodsTypeCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品分类名称">
            <el-input v-model="form.goodsTypeName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品类型id">
            <el-input v-model="form.goodsTagId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品类型编码">
            <el-input v-model="form.goodsTagCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="商品类型名称">
            <el-input v-model="form.goodsTagName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱单位id">
            <el-input v-model="form.boxUnitId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱单位编码">
            <el-input v-model="form.boxUnitCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱单位名称">
            <el-input v-model="form.boxUnitName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="箱数单位计量数">
            <el-input v-model="form.boxUnitCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="主单位id">
            <el-input v-model="form.mainUnitId" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="主单位编码">
            <el-input v-model="form.mainUnitCode" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="主单位名称">
            <el-input v-model="form.mainUnitName" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="主单位计量数">
            <el-input v-model="form.mainUnitCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购数量">
            <el-input v-model="form.buyGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购箱数">
            <el-input v-model="form.buyBoxCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购箱单位数量">
            <el-input v-model="form.buyBoxNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购主单位数量">
            <el-input v-model="form.buyMainNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购含税金额">
            <el-input v-model="form.buyTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购未税金额">
            <el-input v-model="form.buyNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="采购税额">
            <el-input v-model="form.buyTax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售数量">
            <el-input v-model="form.saleGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售箱数">
            <el-input v-model="form.saleBoxCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售箱单位数量">
            <el-input v-model="form.saleBoxNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售主单位数量">
            <el-input v-model="form.saleMainNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售含税金额">
            <el-input v-model="form.saleTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售未税金额">
            <el-input v-model="form.saleNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="销售税额">
            <el-input v-model="form.saleTax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨数量">
            <el-input v-model="form.allotGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨箱数">
            <el-input v-model="form.allotBoxCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨箱单位数量">
            <el-input v-model="form.allotBoxNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨主单位数量">
            <el-input v-model="form.allotMainNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨含税金额">
            <el-input v-model="form.allotTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨未税金额">
            <el-input v-model="form.allotNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="调拨税额">
            <el-input v-model="form.allotTax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损数量">
            <el-input v-model="form.lossGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损箱数">
            <el-input v-model="form.lossBoxCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损箱单位数量">
            <el-input v-model="form.lossBoxNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损主单位数量">
            <el-input v-model="form.lossMainNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损含税金额">
            <el-input v-model="form.lossTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损未税金额">
            <el-input v-model="form.lossNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报损税额">
            <el-input v-model="form.lossTax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢数量">
            <el-input v-model="form.overGoodsCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢箱数">
            <el-input v-model="form.overBoxCount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢箱单位数量">
            <el-input v-model="form.overBoxNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢主单位数量">
            <el-input v-model="form.overMainNum" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢含税金额">
            <el-input v-model="form.overTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢未税金额">
            <el-input v-model="form.overNoTaxAmount" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="报溢税额">
            <el-input v-model="form.overTax" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="id">
            <el-input v-model="form.id" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>

    <vue-context-menu :contextMenuData="contextMenuData"
                      @tableConfig="tableConfig"
                      ></vue-context-menu>
    <!-- 表格配置 -->
    <el-dialog title="表格配置"
               :visible.sync="tableConfigShow"
               width="60%">
      <j-table-column-config :columns.sync="header"  @tabSave="saveHead" />
    </el-dialog>

      <!--表格渲染-->
      <el-table ref="table"
                border
                stripe
                show-summary
                @cell-dblclick="row=>crud.toEdit(row)"
                :data="crud.data"
                size="small"
                style="width: 100%;"
                height="700"
                @header-dragend="changeColWidth"
                :summary-method="crud.sumRow"
                @row-click="crud.selectRow"
                :row-style="crud.rowClass"
                :row-class-name="crud.tableRowClassName"
                @contextmenu.native="showMenu"
                @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" width="55" label="序号"/>
        <el-table-column
          v-if="item.visible"
          v-for="(item, index) in header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp='item.prop'
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template v-if="item.prop =='sort'">
              <div class="handle_move">
                <i :class="scope.row['sort']" />
              </div>
            </template>
            <template v-else>
              <span v-if="item.type == 1" style="margin-left: 10px">{{scope.row[`${item.prop}`]}}</span>
              <span v-if="item.type == 2" style="margin-left: 10px">{{ parseTime(scope.row[`${item.prop}`])}}</span>
              <span v-if="item.type == 3" style="margin-left: 10px">{{ getDict(`this.dict.label.${item.dictionary}["${scope.row[item.prop]}"]`) }}</span>
            </template>
          </template>
        </el-table-column>
<!--        <el-table-column v-if="columns.visible('busDate')" prop="busDate" label="业务日期">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.busDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column v-if="columns.visible('warehouseId')" prop="warehouseId" label="仓库id" />-->
<!--        <el-table-column v-if="columns.visible('warehouseCode')" prop="warehouseCode" label="仓库编码" />-->
<!--        <el-table-column v-if="columns.visible('warehouseName')" prop="warehouseName" label="仓库名称" />-->
<!--        <el-table-column v-if="columns.visible('orderRemark')" prop="orderRemark" label="单据备注" />-->
<!--        <el-table-column v-if="columns.visible('goodsId')" prop="goodsId" label="商品id" />-->
<!--        <el-table-column v-if="columns.visible('goodsCode')" prop="goodsCode" label="商品编码" />-->
<!--        <el-table-column v-if="columns.visible('goodsName')" prop="goodsName" label="商品名称" />-->
<!--        <el-table-column v-if="columns.visible('packageType')" prop="packageType" label="包装类型(1:纸箱 2:塑箱 3:其他)" />-->
<!--        <el-table-column v-if="columns.visible('barcode')" prop="barcode" label="条形码" />-->
<!--        <el-table-column v-if="columns.visible('boxBarcode')" prop="boxBarcode" label="箱装条形码" />-->
<!--        <el-table-column v-if="columns.visible('helpSign')" prop="helpSign" label="助记符" />-->
<!--        <el-table-column v-if="columns.visible('model')" prop="model" label="规格型号" />-->
<!--        <el-table-column v-if="columns.visible('goodsBrandId')" prop="goodsBrandId" label="商品品牌id" />-->
<!--        <el-table-column v-if="columns.visible('goodsBrandCode')" prop="goodsBrandCode" label="商品品牌编码" />-->
<!--        <el-table-column v-if="columns.visible('goodsBrandName')" prop="goodsBrandName" label="商品品牌名称" />-->
<!--        <el-table-column v-if="columns.visible('goodsTypeId')" prop="goodsTypeId" label="商品分类id" />-->
<!--        <el-table-column v-if="columns.visible('goodsTypeCode')" prop="goodsTypeCode" label="商品分类编码" />-->
<!--        <el-table-column v-if="columns.visible('goodsTypeName')" prop="goodsTypeName" label="商品分类名称" />-->
<!--        <el-table-column v-if="columns.visible('goodsTagId')" prop="goodsTagId" label="商品类型id" />-->
<!--        <el-table-column v-if="columns.visible('goodsTagCode')" prop="goodsTagCode" label="商品类型编码" />-->
<!--        <el-table-column v-if="columns.visible('goodsTagName')" prop="goodsTagName" label="商品类型名称" />-->
<!--        <el-table-column v-if="columns.visible('boxUnitId')" prop="boxUnitId" label="箱单位id" />-->
<!--        <el-table-column v-if="columns.visible('boxUnitCode')" prop="boxUnitCode" label="箱单位编码" />-->
<!--        <el-table-column v-if="columns.visible('boxUnitName')" prop="boxUnitName" label="箱单位名称" />-->
<!--        <el-table-column v-if="columns.visible('boxUnitCount')" prop="boxUnitCount" label="箱数单位计量数" />-->
<!--        <el-table-column v-if="columns.visible('mainUnitId')" prop="mainUnitId" label="主单位id" />-->
<!--        <el-table-column v-if="columns.visible('mainUnitCode')" prop="mainUnitCode" label="主单位编码" />-->
<!--        <el-table-column v-if="columns.visible('mainUnitName')" prop="mainUnitName" label="主单位名称" />-->
<!--        <el-table-column v-if="columns.visible('mainUnitCount')" prop="mainUnitCount" label="主单位计量数" />-->
<!--        <el-table-column v-if="columns.visible('buyGoodsCount')" prop="buyGoodsCount" label="采购数量" />-->
<!--        <el-table-column v-if="columns.visible('buyBoxCount')" prop="buyBoxCount" label="采购箱数" />-->
<!--        <el-table-column v-if="columns.visible('buyBoxNum')" prop="buyBoxNum" label="采购箱单位数量" />-->
<!--        <el-table-column v-if="columns.visible('buyMainNum')" prop="buyMainNum" label="采购主单位数量" />-->
<!--        <el-table-column v-if="columns.visible('buyTaxAmount')" prop="buyTaxAmount" label="采购含税金额" />-->
<!--        <el-table-column v-if="columns.visible('buyNoTaxAmount')" prop="buyNoTaxAmount" label="采购未税金额" />-->
<!--        <el-table-column v-if="columns.visible('buyTax')" prop="buyTax" label="采购税额" />-->
<!--        <el-table-column v-if="columns.visible('saleGoodsCount')" prop="saleGoodsCount" label="销售数量" />-->
<!--        <el-table-column v-if="columns.visible('saleBoxCount')" prop="saleBoxCount" label="销售箱数" />-->
<!--        <el-table-column v-if="columns.visible('saleBoxNum')" prop="saleBoxNum" label="销售箱单位数量" />-->
<!--        <el-table-column v-if="columns.visible('saleMainNum')" prop="saleMainNum" label="销售主单位数量" />-->
<!--        <el-table-column v-if="columns.visible('saleTaxAmount')" prop="saleTaxAmount" label="销售含税金额" />-->
<!--        <el-table-column v-if="columns.visible('saleNoTaxAmount')" prop="saleNoTaxAmount" label="销售未税金额" />-->
<!--        <el-table-column v-if="columns.visible('saleTax')" prop="saleTax" label="销售税额" />-->
<!--        <el-table-column v-if="columns.visible('allotGoodsCount')" prop="allotGoodsCount" label="调拨数量" />-->
<!--        <el-table-column v-if="columns.visible('allotBoxCount')" prop="allotBoxCount" label="调拨箱数" />-->
<!--        <el-table-column v-if="columns.visible('allotBoxNum')" prop="allotBoxNum" label="调拨箱单位数量" />-->
<!--        <el-table-column v-if="columns.visible('allotMainNum')" prop="allotMainNum" label="调拨主单位数量" />-->
<!--        <el-table-column v-if="columns.visible('allotTaxAmount')" prop="allotTaxAmount" label="调拨含税金额" />-->
<!--        <el-table-column v-if="columns.visible('allotNoTaxAmount')" prop="allotNoTaxAmount" label="调拨未税金额" />-->
<!--        <el-table-column v-if="columns.visible('allotTax')" prop="allotTax" label="调拨税额" />-->
<!--        <el-table-column v-if="columns.visible('lossGoodsCount')" prop="lossGoodsCount" label="报损数量" />-->
<!--        <el-table-column v-if="columns.visible('lossBoxCount')" prop="lossBoxCount" label="报损箱数" />-->
<!--        <el-table-column v-if="columns.visible('lossBoxNum')" prop="lossBoxNum" label="报损箱单位数量" />-->
<!--        <el-table-column v-if="columns.visible('lossMainNum')" prop="lossMainNum" label="报损主单位数量" />-->
<!--        <el-table-column v-if="columns.visible('lossTaxAmount')" prop="lossTaxAmount" label="报损含税金额" />-->
<!--        <el-table-column v-if="columns.visible('lossNoTaxAmount')" prop="lossNoTaxAmount" label="报损未税金额" />-->
<!--        <el-table-column v-if="columns.visible('lossTax')" prop="lossTax" label="报损税额" />-->
<!--        <el-table-column v-if="columns.visible('overGoodsCount')" prop="overGoodsCount" label="报溢数量" />-->
<!--        <el-table-column v-if="columns.visible('overBoxCount')" prop="overBoxCount" label="报溢箱数" />-->
<!--        <el-table-column v-if="columns.visible('overBoxNum')" prop="overBoxNum" label="报溢箱单位数量" />-->
<!--        <el-table-column v-if="columns.visible('overMainNum')" prop="overMainNum" label="报溢主单位数量" />-->
<!--        <el-table-column v-if="columns.visible('overTaxAmount')" prop="overTaxAmount" label="报溢含税金额" />-->
<!--        <el-table-column v-if="columns.visible('overNoTaxAmount')" prop="overNoTaxAmount" label="报溢未税金额" />-->
<!--        <el-table-column v-if="columns.visible('overTax')" prop="overTax" label="报溢税额" />-->
<!--        <el-table-column v-if="columns.visible('id')" prop="id" label="id" />-->
<!--        <el-table-column v-permission="['admin','reportDailyInventory:edit','reportDailyInventory:del']" label="操作" width="150px" align="center">-->
<!--          <template slot-scope="scope">-->
<!--            <udOperation-->
<!--              :data="scope.row"-->
<!--              :permission="permission"-->
<!--            />-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
    <pagination/>
<!--    <el-pagination-->
<!--      :current-page.sync="query.page"-->
<!--      :page-size.sync="query.size"-->
<!--      :total="crud.page.total"-->
<!--      layout="prev, pager, next"-->
<!--      style="margin-top: 8px; position: fixed;bottom:35px"-->
<!--      @size-change="onGet"-->
<!--      @current-change="onGet"-->
<!--    />-->
    </div>
  
</template>

<script>
import crudReportDailyInventory from '@/api/erp/reportDailyInventory'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

import {getBasGoodsTypeTree} from "@/api/erp/basGoodsType";
import Treeselect from '@riophae/vue-treeselect'
import {get} from '@/api/erp/reportDailyInventory'

import { publicListKey } from "@/utils/key";
import {getHeaderProperties} from "@/api/erp/headerProperties";
import {manyTableMixin} from "@/mixins/manyTableMixin";
import  jTableColumnConfig  from "@/components/jTableColumnConfig/jTableColumnConfig";



// crud交由presenter持有
const defaultCrud = CRUD({ title: '每日进销存报表',
  optShow: {
    add: false,
    edit: false,
    del: false,
    download: true,
    leadingIn: false,
    enable: false,
    disable: false,
    pass: false,
    reject: false,
    invalid: false,
    recover: false,
    downloadDetail: false,
    print: false,
    printDetail: false
  },
  queryOnPresenterCreated:false,
  url: 'api/reportDailyInventory', sort: '',
  crudMethod: { ...crudReportDailyInventory }})
const defaultForm = { busDate: null, warehouseId: null, warehouseCode: null, warehouseName: null, orderRemark: null, goodsId: null, goodsCode: null, goodsName: null, packageType: null, barcode: null, boxBarcode: null, helpSign: null, model: null, goodsBrandId: null, goodsBrandCode: null, goodsBrandName: null, goodsTypeId: null, goodsTypeCode: null, goodsTypeName: null, goodsTagId: null, goodsTagCode: null, goodsTagName: null, boxUnitId: null, boxUnitCode: null, boxUnitName: null, boxUnitCount: null, mainUnitId: null, mainUnitCode: null, mainUnitName: null, mainUnitCount: null, buyGoodsCount: null, buyBoxCount: null, buyBoxNum: null, buyMainNum: null, buyTaxAmount: null, buyNoTaxAmount: null, buyTax: null, saleGoodsCount: null, saleBoxCount: null, saleBoxNum: null, saleMainNum: null, saleTaxAmount: null, saleNoTaxAmount: null, saleTax: null, allotGoodsCount: null, allotBoxCount: null, allotBoxNum: null, allotMainNum: null, allotTaxAmount: null, allotNoTaxAmount: null, allotTax: null, lossGoodsCount: null, lossBoxCount: null, lossBoxNum: null, lossMainNum: null, lossTaxAmount: null, lossNoTaxAmount: null, lossTax: null, overGoodsCount: null, overBoxCount: null, overBoxNum: null, overMainNum: null, overTaxAmount: null, overNoTaxAmount: null, overTax: null, id: null }
export default {
  name: 'ReportDailyInventory',
  components: { pagination, crudOperation, rrOperation, udOperation,Treeselect,jTableColumnConfig },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud(),publicListKey,manyTableMixin],
  dicts:['common_order_status'],
  mounted(){
    this.crud.props.searchToggle =false
  },
  created() {
    getBasGoodsTypeTree({size:999}).then(res=>{
      this.areaList = res.data
    })
  },
  data() {
    return {
      total:0,
      areaList:[],
      orderType:[],
      orderStatus:[],
      dialogVisible:false,
      dataExtent:[],
      goodsTypeIds:[],
      goodsBrandIds:[],
      warehouseIds:[],
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      permission: {
        add: ['admin', 'reportDailyInventory:add'],
        edit: ['admin', 'reportDailyInventory:edit'],
        del: ['admin', 'reportDailyInventory:del'],
        import: ['admin', 'reportDailyInventory:import'],
        export: ['admin', 'reportDailyInventory:export'],
        copy: ['admin', 'reportDailyInventory:copy'],
        upload: ['admin', 'reportDailyInventory:upload'],
        download: ['admin', 'reportDailyInventory:download'],
      },
      rules: {
        goodsId: [
          { required: true, message: '商品id不能为空', trigger: 'blur' }
        ]
      } ,
      dataExtent:[],
    }
  },
  watch: {
  },
  methods: {
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
  getValue(e){
    this.query.startDate = this.dataExtent[0]
    this.query.endDate = this.dataExtent[1]
  },
  normalizer(node) {
    //去掉children=[]的children属性
    if (node.children == null || node.children.length == 0) {
      delete node.children;
    }
    return {
      id: node.id,
      label: node.name,
      children: node.children
    }
  },
  init(){
    this.page = 1
  },
  onGet(){
    const that =this
    get(this.query).then(res=>{
      that.crud.data = res.data.content
      that.crud.page.total = res.data.totalElements
      console.log(that.total)
    })
  },
  resetQuery(){
    this.query = {
      customerIds:null,
      customerKeyword:'',
      endDate:null,
      orderCode:null,
      orderType: null,
      goodsKeyword:'',
      goodsTypeIds:null,
      goodsBrandIds:null,
      orderRemark:'',
      goodsRemark: '',
      orderStatus: null,
      warehouseIds: null,
      startDate:null,
      page:1,
      size:10,
    }
    this.goodsTypeIds = []
    this.orderType  = []
    this.goodsBrandIds = []
    this.orderStatus  = []
    this.warehouseIds = []
    this.dataExtent = []
    this.crud.resetQuery()
    this.onGet()
  },
  queryReport(){
    // this.query.goodsTypeIds = this.goodsTypeIds.length?this.goodsTypeIds.join(','):''
    this.query.orderType = this.orderType.length?this.orderType.join(','):''
    // this.query.goodsBrandIds = this.goodsBrandIds.length?this.goodsBrandIds.join(','):''
    this.query.orderStatus = this.orderStatus.length?this.orderStatus.join(','):''
    // this.query.warehouseIds= this.warehouseIds.length?this.warehouseIds.join(','):''
    this.init()
    this.onGet()
    this.crud.props.searchToggle = false
  }
  }
}
</script>

<style scoped>
  .table-img {
    display: inline-block;
    text-align: center;
    background: #ccc;
    color: #fff;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    width: 32px;
    height: 32px;
    line-height: 32px;
  }
  .flex{
    display: flex;
  }
  .fow-reverse{
    flex-direction: row-reverse;
  }
</style>
